<template>
  <div class="content">
    <div class="TitleBar">
      <TitleBar :imgUrl="url" :Title="'我的订单'"></TitleBar>
    </div>
    <div class="main">
      <div class="main_box" v-for="(item,index) in orderData" :key="index">
        <div class="order_table_head">
          <div class="orderNumber color-yellow">
            <div class="orderNumberText">订单编号:</div>
            <span>{{ item.order_number }}</span>
          </div>
          <div class="orderTime">
            <div class="orderTimeText">下单时间:</div>
            <span>{{ item.createTime }}</span>
          </div>
        </div>
        <el-table :data="item.goods_info" style="width: 100%" class="table">
          <el-table-column width="100">
          </el-table-column>
          <el-table-column prop="goods_info" width="100">
            <template scope="scope">
              <img class="img" :src="scope.row.goods_info.goods_img " alt="">
            </template>
          </el-table-column>
          <el-table-column prop="goods_info" label="商品名称" width="265">
            <template scope="scope">
              {{ scope.row.goods_info.goods_name }}
            </template>
          </el-table-column>
          <el-table-column prop="goods_info" label="单价(元)" width="240">
            <template scope="scope">
              {{ scope.row.goods_info.goods_pprice }}
            </template>
          </el-table-column>
          <el-table-column prop="goods_info" label="数量" width="240">
            <template scope="scope">
              {{ scope.row.goods_num }}
            </template>
          </el-table-column>
          <el-table-column prop="goods_info" label="小计(元)" width="240">
            <template scope="scope">
              <span class="color-yellow">{{ scope.row.goods_info.goods_pprice*scope.row.goods_num}}</span>
            </template>
          </el-table-column>
        </el-table>
        <div class="footer">
          <div class="footer_left">
            共<span class="order_num">{{ item.goods_info.length }}</span>件商品
          </div>
          <div class="footer_right">
            <div class="footer_right_text">合计:</div>
            <div class="footer_right_price">{{item.total}}元</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import TitleBar from "../components/TitleBar.vue";
export default {
  data() {
    return {
      orderData: [],
      url: require("../static/imgs/订单.png"),
    };
  },
  components: {
    TitleBar,
  },
  created() {
    this.getOrderData();
  },
  methods: {
    async getOrderData(pageNumber,pageSize,status){
      const res = await this.$http.post('/orders/getOrder',{pageNumber,pageSize,status})
      if(res.status == 200){
        res.data.result.list.forEach(item=>{
          item.goods_info = JSON.parse(item.goods_info)
        })
        this.orderData = [...res.data.result.list]
      }
    },
  },
};
</script>

<style scoped>
.color-yellow{
  color: #ff6700;
}
.main {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.main_box {
  width: 80%;
  background-color: #ffffff;
  margin-top: 20px;
  margin-bottom: 20px;
}
.order_table_head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 40px;
  padding: 10px;
  border-bottom: 1px solid #ff6700;
}
.orderNumber {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.orderTime {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.footer {
  display: flex;
  height: 40px;
  padding: 10px;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #ff6700;
}
.order_num {
  margin-right: 6px;
  margin-left: 6px;
  color: #ff6700;
}
.footer_right {
  display: flex;
}
.footer_right {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #ff6700;
}
.footer_right_text {
  font-size: 14px;
  margin-right: 20px;
}
.footer_right_price {
  font-size: 22px;
}
.img{
  width: 80px;
}
.table{
  font-size: 18px;
}
</style>